package com.rainman.simpleredis.demo.controller;


import com.rainman.simpleredis.core.SimpleRedis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 测试分布式悲观锁
 *
 */

@RestController
@RequestMapping("/lock")
public class DemoDLockController {

    @Autowired
    SimpleRedis simpleRedis;

    @RequestMapping("/lock")
    public String lock(){
        System.out.println("进入方法");
        Boolean sss = simpleRedis.dLock("sss", 2000L);

        if(sss){
            System.out.println("成功");
            return "成功";
        }else {

            System.out.println("失败");
            return "失败";
        }

    }

}
